﻿//是否下载首页
const downIndexHtml=false;
const indexHtmlUrl="http://minglie.gitee.io/ming_api_mock_plugins/mi_react_quick_start/index.html"
const appjsxUrl="http://minglie.gitee.io/ming_api_mock_plugins/mi_react_quick_start/App.jsx"
let existsAppjsx= fs.existsSync("./App.jsx")
let existsIndexHtml= fs.existsSync("./index.html")
//下载默认jsx
if(!existsAppjsx){
     M.get(appjsxUrl).then(d=>{
         M.writeFile("./App.jsx",d);
     })
}
//下载默认indexHtml
if(!existsIndexHtml && downIndexHtml){
    M.get(indexHtmlUrl).then(d=>{
        M.writeFile("./index.html",d);
    })

}


app.begin(async (req, res) => {
    console.log("req ", req.url)
    var pathname = url_module.parse(req.url).pathname;
    if(pathname=="/index.html" && downIndexHtml==false){
        await  res.renderUrl(indexHtmlUrl);
    }
})
